package com.atguigu.ssyx.mq.service;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * ClassName: RabbitService
 * Package: com.atguigu.ssyx.mq
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-09-27
 * Time: 16:17
 */

@Service
public class RabbitService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    //发送消息的方法
    public boolean sendMessage(String exchange, String routingKey, Object message) {
        //参数分别是交换机 路由Key 消息
        rabbitTemplate.convertAndSend(exchange, routingKey, message);

        return true;
    }

}
